<template>
  <div>
    <el-table :data="list" style="width: 100%">
      <el-table-column label="ID" width="180">
        <template slot-scope="scope">
          <i class="el-icon-lock"></i>
          <span style="margin-left: 10px">{{scope.row.bid}}</span>
        </template>
      </el-table-column>
      <el-table-column label="客户反馈信息" width="180">
        <template slot-scope="scope">
          <el-popover placement="top">
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.backmassage }}</el-tag>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status == 1" effect="dark" type="success">已读</el-tag>
          <el-tag v-else effect="dark" type="info">未读</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="查看详细">
        <template slot-scope="scope">
          <el-button @click="changeState(scope.row,1)" type="primary">查看</el-button>
          <el-button size="mini" type="warning" @click="changeState(scope.row,0)">修改</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :current-page="page"
      :total="total"
      :page-size="pageSize"
      @current-change="goPage"
      hide-on-single-page
    ></el-pagination>
  </div>
</template>


<script>
// import Base64 from 'base-64'
export default {
  data() {
    return {
      pageSize: 8,
      total: 100,
      page: 1,
      status  : 0,
      list: []
    };
  },
created(){
    // ID加密
    this.status = this.$route.params.status;
    // this.bid = Base64.encode('bid');
    this.getData()
  },
  methods: {
    getData() {
      this.$http({
        url: "/admin/notice/getAll",
        params:{
          page:this.page,
          pageSize:this.pageSize,
        }
      }).then((res) => {
        console.log(res);
        this.list = res
      });
    },
    goPage(page) {
      this.page = page;
      this.getData();
    },
    changeState(scope,status) {
      console.log(scope);
      this.$router.push({
        path: "/message/getone",
        query: {
          bid: scope.bid
        }
      });
      console.log(status);
      this.$http({
          url: "admin/notice/update",
          params: {
            bId: scope.bid,
            status
          },
        }).then((res) => {
          this.getData();
          this.$message({
            type: res.Integer == 1 ? "error" : "success",
            message: '修改审核状态成功',
          });
          console.log(res);
          if (res.integer == 1) {
            this.getData();
          }
        });
    },
  },
};
</script>

<style scoped>
.name-wrapper{
  overflow: hidden;
  text-overflow:ellipsis;
  white-space: nowrap;
}
.el-table{
  width: 100%;
  margin-bottom: 20px;
}
</style>